<?php
/**
 * Created by PhpStorm.
 * User: reshared
 * Date: 17-7-23
 * Time: 下午5:28
 */

namespace App\Http\Controllers\Home;


use App\Http\Controllers\Controller;
use App\Repository\ArticleRepository;
use Illuminate\Http\Response;

class AjaxController extends Controller
{
    protected $articleRepository;

    public function __construct(ArticleRepository $articleRepository)
    {
        $this->articleRepository = $articleRepository;
    }
    public function blog($page)
    {
        $data = $this->articleRepository->getList($page, 8);
        return $this->ajaxReturn($data);
    }

    private function ajaxReturn($data = [], $code = 0)
    {
        return response()->json(['code'=>$code, 'data'=>$data]);
    }
}